<?php
class FriendAction extends CommonAction
{
	/**
	 * Ajax方法，添加好友
	 */
	public function add() {
		$friend_id = $_GET['friend_id'];
		$friend_dao = new FriendModel();
		$friend_dao->buildRelation($_SESSION['user']['id'], $friend_id);
		
		$this->ajaxReturn(null, null, 1);
	}
	
	public function listFriends() {
		$friend_dao = new FriendModel();
		$friends = $friend_dao->getFriendsByUserId($_SESSION['user']['id']);
		
		$this->assign("friends", $friends);
		$this->display();
	}
	
	public function friendPage() {
		$friend_id = $_GET['friend_id'];
		$user_dao = new UserModel();
		$friend = $user_dao->getById($friend_id);
		$note_dao = new NoteModel();
		$notes = $note_dao->getByUserId($friend_id);
		$this->assign("notes", $notes);
		$this->assign("friend", $friend);
		$this->display();
	}
}

?>